//
//  ViewController.m
//  王宇先_07_导航栏控制器
//
//  Created by wyx on 16/3/17.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor redColor];
    [self configForNavigationItem];
}
- (void)configForNavigationItem{
    
    //中间title
    self.navigationItem.title = @"第一页";
    //左边(leftBarButtonItem)
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(handleAdd:)]autorelease];
    //右边(rightBarButtonItem)
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(handleSearch:)]autorelease];
//    UIBarButtonItem *r1 = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(handleNext:)];
//    UIBarButtonItem *r2 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"gur-project-10.png"] style:UIBarButtonItemStylePlain target:self action:@selector(handleMap:)];
//    self.navigationItem.rightBarButtonItems = @[r1, r2];
    //[r1 release];
    //[r2 release];
}
//推出第二界面
- (void)handleAdd:(UIBarButtonItem *)add {
    SecondViewController *second = [[SecondViewController alloc] init];
    [self.navigationController pushViewController:second animated:YES];
    [second release];
}
//推出第三界面
- (void)handleSearch:(UIBarButtonItem *)search {
    ThirdViewController *third = [[ThirdViewController alloc] init];
    [self.navigationController pushViewController:third animated:YES];
    [third release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
